<?php
namespace app\banner\validate;
use think\Validate;
class Category extends Validate {
    //验证字段
    protected $rule = [
        'type_name' => ['require'],
        'sort' => ['require'],
        'creater' => ['require'],
        'updater' => ['require'],
        'status' => ['require','number'],
        'ext1' => ['require'],
        'id' => ['require','number'],
    ];
    //返回消息
    protected $message = [
        'type_name.require' => '分类名必须',
        'sort.require' => '排序值必须',
        'creater.require' => '创建者必须',
        'updater.require' => '更新者必须',
        'status.require' => '当前状态必须',
        'status.number' => '当前状态不是数字',
        'ext1.require' => '预留字段1必须',
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
    ];

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['type_name','sort','creater','updater','status','ext1']);
    }

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','type_name','sort','creater','updater','status','ext1']);
    }

    // all_field 场景
    public function sceneAdd(){
        return $this->only(['type_name','sort']);
    }
    // all_field 场景
    public function sceneUpdate(){
        return $this->only(['id','type_name','sort']);
    }
}
